/**
 * ...
 * @author Krzysztof Rozalski
 */

package hapi.physics;
import hapi.math.Vector2D;

class Force {
	
	var vector:Vector2D;
	var n:Float;
	public var neutons(getNeutons, setNeutons):Float;
	
	public static function zero():Force {
		return new Force(0.0, new Vector2D(0.0, 0.0));
	}

	public function new(neutons:Float, direction:Vector2D) {
		this.vector = direction.getNormal();
		this.neutons = neutons;
	}
	
	public function applyOn(mass:Mass):Acceleration {
		return new Acceleration(mass.kilos/this.n, vector.getNormal());
	}
	
	public function add(f:Force):Force {
		vector.plus(f.vector);
		this.n = vector.getLength();
		return this;
	}
	
	public function substract(f:Force):Force {
		vector.minus(f.vector);
		this.n = vector.getLength();
		return this;
	}
	
	function getNeutons() {
		return n;
	}
	
	function setNeutons(n) {
		this.vector.normalize();
		this.vector.mult(n);
		return this.n = n;
	}
}